<template>
	<div class="Image">
	  <div style="height: 800px; width: auto" v-html="poHtmlCode" />
	</div>
</template>

<script>
	import axios from 'axios';
	  export default{
	    name: 'Image',
	    data(){
	      return {
	        poHtmlCode: '',
	
	      }
	    },
	    created: function(){
	      //由于vue中的axios拦截器给请求加token都得是ajax请求，所以这里必须是axios方式去请求后台打开文件的controller
	      axios.post("/api/OpenImage/Image").then((response) => {
	        this.poHtmlCode = response.data;
	
	      }).catch(function (err) {
	        console.log(err)
	      })
	    },
		methods:{
			//控件中的一些常用方法都在这里调用，比如保存，打印等等
			PrintFile() {
				pdfctrl.ShowDialog(4);
			},
			SwitchFullScreen() {
				pdfctrl.FullScreen = !pdfctrl.FullScreen;
			},
			SetPageReal() {
				pdfctrl.SetPageFit(1);
			},
			SetPageFit() {
				pdfctrl.SetPageFit(2);
			},
			SetPageWidth() {
				pdfctrl.SetPageFit(3);
			},
			ZoomIn() {
				pdfctrl.ZoomIn();
			},
			ZoomOut() {
				pdfctrl.ZoomOut();
			},
			FirstPage() {
				pdfctrl.GoToFirstPage();
			},
			PreviousPage() {
				pdfctrl.GoToPreviousPage();
			},
			NextPage() {
				pdfctrl.GoToNextPage();
			},
			LastPage() {
				pdfctrl.GoToLastPage();
			},
			SetRotateRight() {
				pdfctrl.RotateRight();
			},
			SetRotateLeft() {
				pdfctrl.RotateLeft();
			},
			OnPDFCtrlInit() {
				pdfctrl.AddCustomToolButton("打印", "PrintFile()", 6);
				pdfctrl.AddCustomToolButton("-", "", 0);
				pdfctrl.AddCustomToolButton("实际大小", "SetPageReal()", 16);
				pdfctrl.AddCustomToolButton("适合页面", "SetPageFit()", 17);
				pdfctrl.AddCustomToolButton("适合宽度", "SetPageWidth()", 18);
				pdfctrl.AddCustomToolButton("缩小", "ZoomOut()", 17);
				pdfctrl.AddCustomToolButton("放大", "ZoomIn()", 18);
				pdfctrl.AddCustomToolButton("-", "", 0);
				pdfctrl.AddCustomToolButton("首页", "FirstPage()", 8);
				pdfctrl.AddCustomToolButton("上一页", "PreviousPage()", 9);
				pdfctrl.AddCustomToolButton("下一页", "NextPage()", 10);
				pdfctrl.AddCustomToolButton("尾页", "LastPage()", 11);
				pdfctrl.AddCustomToolButton("-", "", 0);
				pdfctrl.AddCustomToolButton("向左旋转90度", "SetRotateLeft()", 12);
				pdfctrl.AddCustomToolButton("向右旋转90度", "SetRotateRight()", 13);
			},
			},
			mounted: function(){
			// 将vue中的方法赋值给window
			window.OnPDFCtrlInit=this.OnPDFCtrlInit;
			window.PrintFile = this.PrintFile;
			window.SwitchFullScreen = this.SwitchFullScreen;
			window.SetPageReal = this.SetPageReal;
			window.SetPageFit = this.SetPageFit;
			window.SetPageWidth = this.SetPageWidth;
			window.ZoomIn = this.ZoomIn;
			window.ZoomOut = this.ZoomOut;
			window.FirstPage = this.FirstPage;
			window.PreviousPage = this.PreviousPage;
			window.NextPage = this.NextPage;
			window.LastPage = this.LastPage;
			window.SetRotateRight = this.SetRotateRight;
			window.SetRotateLeft = this.SetRotateLeft;
			}
	}
</script>

